package engine.asset
{
	import away3d.events.*;
	import engine.core.*;
	import engine.graphics.away3d.*;
	import engine.graphics.shader.*;
	import engine.loaders.*;
	
	public class RxAssetModel extends RxAsset
	{
		protected var m_shaderFamily:RxShaderFamilyBase;
		private static var s_type:int;
		public static var s_shaderFamilyManager:RxShaderFamilyManager;
		
		public function RxAssetModel(shader:RxShaderFamilyBase, type:int = 0)
		{
			super(type != 0 ? type : s_type);
			this.m_shaderFamily = shader;
		}
		
		public static function Initialize() : void
		{
			s_type = RxAsset.RegisterType("model", CreateFromXML);
		}
		
		public static function CreateFromXML(xml:XML, param2:String) : RxAssetModel
		{
			var model:RxAssetModel = null;
			var name:* = xml.@name;
			var url:* = xml.@url;
			url = RxUtilities.MergePath(param2, url);
			var shader:* = xml.@shader;
			model = Create(url, name, shader);
			return model;
		}
		
		public static function Create(url:String, name:String, shader:String) : RxAssetModel
		{
			var _loc_4:* = s_shaderFamilyManager.GetShaderFamily(shader);
			return Create2(url, name, _loc_4);
		}
		
		public static function Create2(param1:String, param2:String, param3:RxShaderFamilyBase) : RxAssetModel
		{
			var _loc_4:RxAssetModel = null;
			if (param1 != "")
			{
				_loc_4 = GetByURL(param1);
				if (_loc_4 != null)
				{
					var _loc_5:* = _loc_4;
					var _loc_6:* = _loc_4.m_references + 1;
					_loc_5.m_references = _loc_6;
					return _loc_4;
				}
			}
			_loc_4 = new RxAssetModel(param3);
			_loc_4.SetURL(param1);
			_loc_4.SetName(param2);
			return _loc_4;
		}
		
		public static function GetByURL(param1:String) : RxAssetModel
		{
			return RxAssetModel(_getByURL(param1, s_type));
		}
		
		public static function SetShaderFamilyManager(param1:RxShaderFamilyManager) : void
		{
			s_shaderFamilyManager = param1;
		}

	}
}